<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>

<div id="contentmid">

<s:if test="#session.amministratore == true">
<h3><s:text name="message.notlogged"/></h3>
</s:if>
<s:else>

<div class="midheading">
          <h2></h2>
</div>
<s:if test="#session.carrello == null || #session.carrello.carrello.size() == 0">
<div class="midboldtxt2">Il tuo carrello è vuoto!</div>
</s:if>
<s:else>
<table class="carrelloTable">
<thead class="carrelloTable">
<tr class="carrelloTable" >

<th scope="col" class="carrelloTable">Prodotto</th>
<th scope="col" class="carrelloTable">Quantità</th>
<th scope="col" class="carrelloTable">Prezzo</th>
<th scope="col" class="carrelloTable">Totale</th>
<th scope="col" class="carrelloTable">Opzioni</th>

</tr>
</thead>


<s:iterator value="#session.carrello.carrello">
<tbody class="carrelloTable">
<tr class="carrelloTable">
<td><s:property value="nomeArticolo"/></td>
<td><s:form action="aggiornaQuantita" >
		<s:textfield name="quantita" size="1" theme="simple" class="moreproject" />
   		<s:submit value="Aggiorna" align="center" />
   			<s:hidden name="idArticoloToUpd" value="%{idArticolo}"/>
		</s:form></td>
<td><s:property value="prezzo"/>€</td>
<td><s:property value="prezzoTotArticolo"/>€</td>
<td><a href="<s:url action='eliminaArticolo'><s:param name="idArticoloToRemove" value="%{idArticolo}"/></s:url>" class="moreproject">Elimina</a></td>
</tr>
</tbody>
</s:iterator>
<thead class="carrelloTable">
<tr>
<th scope="col" class="carrelloTable"></th>
<th scope="col" class="carrelloTable"></th>
<th scope="col" class="carrelloTable">TOTALE</th>
<th scope="col" class="carrelloTable">ORDINE:</th>
<th scope="col" class="carrelloTable"><s:property value="#session.carrello.totCarrello"/>€</th>
</tr>
</thead>
</table>
</s:else>

<table>
<tr>
	<td><s:form action="catalogo" >
    	<s:submit value="Torna al Catalogo" align="center" />
	</s:form></td>
	<s:if test="#session.carrello != null && #session.carrello.carrello.size() != 0">
	<td><s:form action="svuotaCarrello" >
   		<s:submit value="Svuota Carrello" align="center" />
	</s:form></td>
	<s:if test="#session.loggedUser != null">
	<td><s:form action="showDatiAcquisto" >
  		<s:submit value="Prosegui >" align="center" />
	</s:form></td></s:if>
	    <s:else>
       
            <td>
	            <s:form action="effettua_login">
	            <s:submit value="Prosegui >"/>
	            <s:hidden name="messaggioLogin" value="true"/>
	            </s:form>
            </td>
       
        </s:else>
</s:if>
</tr>
</table>
</s:else>
</div>
